"use strict"

exports.index = async function(){
    this.view = "branch/roleDetail";
    let branch=this.branch;
    let server = this.model.branch("server",branch);
    let keys = ["name"]
    let ret= await server.mget(keys);
    let data={'server':{}};
	for(let k in ret){
	    let v = ret[k];
	    let sid = v._id;
	    if(!data["sid"]){
	        data["sid"] = sid;
	    }
	    data["server"][sid] = v.name;
	}
	return data;
}

exports.query = async function(){
	this.output='json';
	let sid = this.get("sid","int");
    let idType = this.get("idType","int");
    let id=this.get('id','string');
    let branch=this.branch;
//    console.log(`sid:${sid}`);
    if(this.req.body.idType==3){
    	//openid模式
    	let openid_model = this.model.branch("openid",branch);
    	let ret=await openid_model.find({'openid':id},{'fields':['guid']});
    	if(!ret){
    		 return this.error('查无此人');
    	}
    	this.req.body['guid']=ret.guid; 
    }
    return this.library("game/request",branch,sid,'/queryRoleDetail/role',this.req.body);
}

exports.copy996 = async function(){
    this.output='json';
    let branch=this.branch;
    let sid = this.get("sid","int");
    return this.library("game/request",branch,sid,'/queryRoleDetail/copy996',this.req.body);
}
